<?php
/**
 * Standard Document List Grid
 * 
 * @author Xavier VILAIN
 * @package Nawa\MedicalStudy\MedicalCenter
 * @license
 * 
 */
use Fox\Generator;
use Fox\Grid\FieldCat\Field\Renderer\Anchor;
use Fox\Grid;
$grid = new Grid('documents');
$grid->fieldcat(array('docid','filename','doctype',array('cdate','udate'),
array('cname','uname'),'idele'));
$grid->fieldcat()->field('docid')->hidden();
$grid->fieldcat()->field('udate')->displayTime();
$grid->fieldcat()->field('uname')->width(10);
$grid->fieldcat()->switchToObjectMode();
$grid->fieldcat()->setGenerators(array(
	'filename' => Generator::useFunction(function($object) {
		return $object->document()->filename;
	}),
	'doctype' => Generator::useFunction(function($object) {
		return $object->document()->doctype()->label();
	}),
	'idele' => Generator::useFunction(function($object) {
		return '?';
	}),
));
$grid->fieldcat()->setFieldAttr(array('filename'), 'renderers',new Anchor(
Generator::url('core','files','download',
array('id' => Generator::useAttribute('docid'),
					 'xvtrs' => Generator::useValue('none')))
));
return $grid;